package com.bs.modules.use.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bs.common.utils.PageUtils;
import com.bs.common.utils.Query;
import com.bs.modules.use.dao.AppPriceDao;
import com.bs.modules.use.entity.AppPriceEntity;
import com.bs.modules.use.service.AppPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("appPriceService")
public class AppPriceServiceImpl extends ServiceImpl<AppPriceDao, AppPriceEntity> implements AppPriceService {

  @Autowired
  private AppPriceDao appPriceDao;

  @Override
  public PageUtils queryPage(Map<String, Object> params) {
    IPage<AppPriceEntity> page = this.page(
      new Query<AppPriceEntity>().getPage(params),
      new QueryWrapper<AppPriceEntity>()
    );



    return new PageUtils(page);
  }

  @Override
  public AppPriceEntity findNewInfo() {

    List<AppPriceEntity> list = appPriceDao.findNewInfo();

    if (list.size() != 0) {
      return list.get(0);
    } else {
      return null;
    }

  }

  @Override
  public AppPriceEntity findInfoByPriceId(String powerPriceid) {


    return appPriceDao.findInfoByPriceId(powerPriceid);
  }

}
